﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Fluent="clr-namespace:Fluent"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

  <ControlTemplate x:Key="BackstageToggleButtonControlTemplate" TargetType="{x:Type Fluent:Backstage}">
    <Border x:Name="border2" MinWidth="56" Height="24" CornerRadius="2,2,0,0"
            Background="{TemplateBinding Background}" Margin="0,0,0,1">
      <Border x:Name="border1" BorderThickness="1,1,1,0" CornerRadius="2,2,0,0">
        <Border.BorderBrush>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#997C7C7C" Offset="0" />
            <GradientStop Color="#7F848484" Offset="1" />
          </LinearGradientBrush>
        </Border.BorderBrush>
        <Border x:Name="border" BorderThickness="1,1,1,0" CornerRadius="1,1,0,0">
          <Border.BorderBrush>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#72FFFFFF" Offset="0" />
              <GradientStop Color="#4CFFFFFF" Offset="1" />
            </LinearGradientBrush>
          </Border.BorderBrush>
          <Border.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#3FFFFFFF" Offset="0" />
              <GradientStop Offset="1" Color="#3FFFFFFF" />
              <GradientStop Offset="0.5" />
            </LinearGradientBrush>
          </Border.Background>
          <Grid>
            <Rectangle x:Name="rectangle_Copy" StrokeThickness="0">
              <Rectangle.Fill>
                <RadialGradientBrush Center="0.5,0.0" GradientOrigin="0.5,0.0" RadiusX="0.501"
                                     RadiusY="0.319">
                  <GradientStop Color="#59FFFFFF" />
                  <GradientStop Offset="1" />
                </RadialGradientBrush>
              </Rectangle.Fill>
            </Rectangle>
            <Rectangle x:Name="rectangle" StrokeThickness="0">
              <Rectangle.Fill>
                <RadialGradientBrush Center="0.5,1.001" GradientOrigin="0.5,1.001" RadiusX="0.496"
                                     RadiusY="0.554">
                  <GradientStop Color="#66FFFFFF" Offset="0.018" />
                  <GradientStop Offset="1" />
                </RadialGradientBrush>
              </Rectangle.Fill>
            </Rectangle>
            <!--<TextBlock Margin="2,0,2,2" Text="{TemplateBinding Header}" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Center" VerticalAlignment="Center"/>-->
            <ContentPresenter x:Name="contentPresenter" ContentSource="Header" VerticalAlignment="Center"
                              HorizontalAlignment="Center" />
          </Grid>
        </Border>
      </Border>
    </Border>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="BorderBrush" TargetName="border1">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#A07C7C7C" Offset="0" />
              <GradientStop Color="#84848484" Offset="1" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
        <Setter Property="Background" TargetName="border">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#4CFFFFFF" Offset="0" />
              <GradientStop Color="#25FFFFFF" Offset="1" />
              <GradientStop Offset="0.5" Color="#19FFFFFF" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush" TargetName="border">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#7FFFFFFF" Offset="0" />
              <GradientStop Color="#59FFFFFF" Offset="1" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
        <Setter Property="Fill" TargetName="rectangle_Copy">
          <Setter.Value>
            <RadialGradientBrush Center="0.5,0" GradientOrigin="0.5,0" RadiusX="0.501" RadiusY="0.319">
              <GradientStop Color="#66FFFFFF" />
              <GradientStop Offset="1" />
            </RadialGradientBrush>
          </Setter.Value>
        </Setter>
        <Setter Property="Fill" TargetName="rectangle">
          <Setter.Value>
            <RadialGradientBrush Center="0.5,1.001" GradientOrigin="0.5,1.001" RadiusX="0.496"
                                 RadiusY="0.554">
              <GradientStop Color="#7FFFFFFF" Offset="0.018" />
              <GradientStop Offset="1" />
            </RadialGradientBrush>
          </Setter.Value>
        </Setter>
      </MultiTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Opacity" TargetName="border2" Value="0.5" />
        <Setter Property="Effect" TargetName="contentPresenter">
          <Setter.Value>
            <Fluent:GrayscaleEffect />
          </Setter.Value>
        </Setter>
      </Trigger>
      <Trigger Property="IsOpen" Value="True">
        <Setter Property="Margin" TargetName="border2" Value="0" />
        <Setter Property="Visibility" TargetName="rectangle" Value="Collapsed" />
        <Setter Property="Visibility" TargetName="rectangle_Copy" Value="Collapsed" />
        <Setter Property="BorderBrush" TargetName="border1">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#99959595" Offset="0" />
              <GradientStop Color="#7F909090" Offset="1" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush" TargetName="border">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#4CFFFFFF" Offset="0" />
              <GradientStop Color="#72FFFFFF" Offset="1" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
        <Setter Property="Background" TargetName="border">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#19FFFFFF" Offset="0" />
              <GradientStop Color="#66FFFFFF" Offset="1" />
              <GradientStop Offset="0.5" Color="#3FFFFFFF" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
      </Trigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True" SourceName="border2" />
          <Condition Property="IsOpen" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" TargetName="rectangle" Value="Collapsed" />
        <Setter Property="Visibility" TargetName="rectangle_Copy" Value="Collapsed" />
        <Setter Property="BorderBrush" TargetName="border1">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#A0A1A1A1" Offset="0" />
              <GradientStop Color="#879A9A9A" Offset="1" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush" TargetName="border">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#59FFFFFF" Offset="0" />
              <GradientStop Color="#7FFFFFFF" Offset="1" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
        <Setter Property="Background" TargetName="border">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
              <GradientStop Color="#26FFFFFF" Offset="0" />
              <GradientStop Color="#7FFFFFFF" Offset="1" />
              <GradientStop Offset="0.5" Color="#4CFFFFFF" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
      </MultiTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <Style TargetType="{x:Type Fluent:Backstage}">
    <Setter Property="Template" Value="{StaticResource BackstageToggleButtonControlTemplate}" />
    <Setter Property="Background" Value="Blue" />
    <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" />
    <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
    <Setter Property="Foreground" Value="White" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Fluent:FrameworkHelper.UseLayoutRounding" Value="True" />
  </Style>

</ResourceDictionary>